<!DOCTYPE html>
{% load static %}
<html lang="zh-cn">
<head>
    <script type='text/javascript' src="static/fybjs/htmlAceControlShow.js"></script>
    <script>
        headLoadFile('新一代工业软件应用商店');
    </script>
    <!--付颖斌的js文件-->
    <script type='text/javascript' src="static/fybjs/httpDataTransFyb.js"></script>
    <script>
        $.ajaxSetup({data:{csrfmiddlewaretoken:'{{ csrf_token }}'}})
    </script>
    <link rel="stylesheet" type="text/css" href="static/css/indexModel.css">

</head>
<body class="no-skin">
<!--导航栏index-->
<script>
    //权限控制
    jumpURL=getAuthURL(window.location.href);
    if(jumpURL!=window.location.href){window.location.href=jumpURL;}else{};
    //加载内容
    shortCutText=['平台主页','数据聚合','情景推荐'];
    shortCutText=[];
    shortCutLiColor=['grey','purple','green'];
    shortCutHref=['#','#','https://www.baidu.com'];
    shortCutSrc=['static/ace/assets/images/avatars/platform.png','static/ace/assets/images/avatars/process.png','static/ace/assets/images/avatars/support.png'];
    navBarShowAceIndexFyb("","新一代工业软件应用商店","工业软件库","欢迎光临",shortCutText, shortCutLiColor, shortCutHref, shortCutSrc);

</script>

<div class="main-container ace-save-state" id="main-container">
    <!--嵌入侧边栏-->
    <div class="sidebar responsive ace-save-state" id="sidebar">
        <!-- 功能按钮区域 -->
        <script>
            buttonClass=['btn btn-success','btn btn-info','btn btn-warning','btn btn-danger'];
            dataToggle=['tab','modal','modal','modal'];
            dataTarget=['#projectManagementDiv','#newProjectModal','#helpModal','#dangerModal'];
            buttonID=['','','',''];
            iClass=['ace-icon fa fa-cog','ace-icon fa fa-table','ace-icon fa fa-users','ace-icon fa fa-bell-o'];
            //leftTopNavBarControlButtonAceFyb(buttonClass, dataToggle, dataTarget, buttonID, iClass);
        </script>
        <!-- 侧边栏 -->
        <script>
            menuList=JSON.parse(getUserMenuList());
            menuActiveID=getNavBarMenuActiveId(getHtmlUrlAlone(location.href),menuList[0]['cotentDataHref'], menuList[0]['cotentMenuID'],"@");
            leftContentNavBarAceFyb(menuList[0]['titleData'], menuList[0]['titleiClass'], menuList[0]['titleHref'], menuList[0]['cotentData'], menuList[0]['contentiClass'], menuList[0]['cotentDataHref'],menuActiveID);
        </script>


    </div>
    <div class="main-content">
        <div class="main-content-inner">
            <!--嵌入面包屑-->
            <script>
                var titleBreadData=['新一代工业软件平台','#'];
                var searchString=['show','请输入名称'];
                var otherBreadData=new Array();
                otherBreadData[0]=['工业软件库','#'];
                otherBreadData[1]=['test','#'];
                testID=breadCrumbsAceFyb(titleBreadData,otherBreadData, searchString);
            </script>

            <div class="page-content">
                <div class="row">
                    <div class="col-sm-6">
                        <div class="tabbable">
                            <ul class="nav nav-tabs" id="myTab">
                                <script type='text/javascript'>
                                    subContentPageAceFyb('所有APP',true,'#');
                                </script>
                            </ul>
                            <div class="tab-content" id="pageContent">
                                <!--开始写入正文-->
                                <div class="widget-main">
                                    <form class="form-horizontal" role="form">
                                <script>

                                var columnName=['class_name', 'class_level', 'class_list_order' ,'id'];
                                var transData={
                                    table:dbTableHead + 'classify_infor',
                                    sqlType:'query',
                                    column:matrixTransStringForSqlColumn(columnName),
                                    userAccount:userAccount,
                                    enterAccount:enterAccount,
                                    restraint:'class_level=1 order by class_list_order ASC',
                                    };
                                queryData=dataTransferFyb('dataTransferFybAdmin','POST',false,transData,);
                                var levelData1=[];
                                levelData1[0]='无';
                                for(var i=0;i<queryData.length; i++)
                                {
                                    levelData1[i+1]=queryData[i]['id']+'|'+ queryData[i]['class_list_order'] + '|' +queryData[i]['class_name'];
                                }
                                //levelData1[queryData.length]='0|0|增加一级分类';
                                labelInputShowAceFyb(['请输入分类名称：','form-levelName-1'],['text','form-levelName-1','请填入分类名称','col-xs-10 col-sm-5'],['','']);
                                labelInputShowAceFyb(['请输入分类序号：','form-levelOrder-1'],['number','form-levelOrder-1','请填入分类序号','col-xs-10 col-sm-5'],['','']);
                                labelInputShowAceFyb(['选择一级节点：','form-level-1'],['select','form-level-1','请填入分类名称','col-xs-10 col-sm-5'],levelData1);
                                labelInputShowAceFyb(['选择二级节点：','form-level-2'],['select','form-level-2','请填入分类名称','col-xs-10 col-sm-5'],[]);
                                labelInputShowAceFyb(['选择三级节点：','form-level-3'],['select','form-level-3','请填入分类名称','col-xs-10 col-sm-5'],[]);
                                </script>
                                        <div class="tab-pane" id="ghi">
                                            <div id="submitButtonFyb" class="btn-group btn-group-sm" >
                                                <button type="button" class="btn btn-info" >
                                                    <span class="glyphicon glyphicon-check"></span>提交
                                                </button>
                                            </div>
                                            <div id="deleteButtonFyb" class="btn-group btn-group-sm" >
                                                <button type="button" class="btn btn-danger" >
                                                    <span class="glyphicon glyphicon-check"></span>删除
                                                </button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                                <script>
                                        //写分类选择框选择事件
                                        var selectBtn = document.getElementById("form-level-1");
                                        var selLevel2=document.getElementById("form-level-2");
                                        selectBtn.onclick =function(){
                                            var resourceSelect=document.getElementById('form-level-1');
                                            var selData1=resourceSelect.value;
                                            var test='无';
                                            $('#form-level-2').empty();
                                            $('#form-level-2').append('<option value="'+test+'" style="width: 100%;">'+test+'</option>');
                                            if(selData1!='无'){
                                                var selData1Matrix=selData1.split('|');
                                                var columnNameTemp=['class_name', 'class_level', 'class_list_order' ,'id'];
                                                var transDataTemp={
                                                    table:dbTableHead + 'classify_infor',
                                                    sqlType:'query',
                                                    column:matrixTransStringForSqlColumn(columnNameTemp),
                                                    userAccount:userAccount,
                                                    enterAccount:enterAccount,
                                                    restraint:'class_level=2 and class_father_id='+ selData1Matrix[0] +' order by class_list_order ASC',
                                                    };
                                                levelDataTemp2=dataTransferFyb('dataTransferFybAdmin','POST',false,transDataTemp,);
                                                if(levelDataTemp2.length==1 && levelDataTemp2[0]['id']==''){
                                                }else{
                                                    for(var j=0; j<levelDataTemp2.length; j++)
                                                    {
                                                        var tempLevelData=levelDataTemp2[j]['id']+'|'+ levelDataTemp2[j]['class_list_order'] + '|' +levelDataTemp2[j]['class_name'];
                                                        $('#form-level-2').append('<option value="'+tempLevelData+'" style="width: 100%;">'+tempLevelData+'</option>');
                                                    }
                                                }
                                            }

                                        }

                                        selLevel2.onclick =function(){
                                            var resourceSelect=document.getElementById('form-level-2');
                                            var selData2=resourceSelect.value;
                                            var test='无';
                                            $('#form-level-3').empty();
                                            $('#form-level-3').append('<option value="'+test+'" style="width: 100%;">'+test+'</option>');
                                            if(selData2!='无'){
                                                var selData2Matrix=selData2.split('|');
                                                var columnNameTemp=['class_name', 'class_level', 'class_list_order' ,'id'];
                                                var transDataTemp={
                                                    table:dbTableHead + 'classify_infor',
                                                    sqlType:'query',
                                                    column:matrixTransStringForSqlColumn(columnNameTemp),
                                                    userAccount:userAccount,
                                                    enterAccount:enterAccount,
                                                    restraint:'class_level=3 and class_father_id='+ selData2Matrix[0] +' order by class_list_order ASC',
                                                    };
                                                levelDataTemp2=dataTransferFyb('dataTransferFybAdmin','POST',false,transDataTemp,);
                                                if(levelDataTemp2.length==1 && levelDataTemp2[0]['id']==''){
                                                }else{
                                                    for(var j=0; j<levelDataTemp2.length; j++)
                                                    {
                                                        var tempLevelData=levelDataTemp2[j]['id']+'|'+ levelDataTemp2[j]['class_list_order'] + '|' +levelDataTemp2[j]['class_name'];
                                                        $('#form-level-3').append('<option value="'+tempLevelData+'" style="width: 100%;">'+tempLevelData+'</option>');
                                                    }
                                                }
                                            }

                                        }

                                        //写提交按钮事件
                                        var btn = document.getElementById("submitButtonFyb");
                                        btn.onclick =function(){
                                            var levelName=document.getElementById("form-levelName-1").valueOf().value;
                                            levelName=levelName.replace("'","");//去掉'符号
                                            levelName=levelName.replace('"','');//去掉"符号
                                            levelName=levelName.replace(',','');//去掉,符号
                                            var levelOrder=document.getElementById("form-levelOrder-1").valueOf().value;
                                            levelOrder=levelOrder.replace("'","");//去掉'符号
                                            levelOrder=levelOrder.replace('"','');//去掉"符号
                                            levelOrder=levelOrder.replace(',','');//去掉,符号

                                            var selectLevel1=document.getElementById('form-level-1');
                                            var selectLevelData1=selectLevel1.value;

                                            var selectLevel2=document.getElementById('form-level-2');
                                            var selectLevelData2=selectLevel2.value;

                                            //alert(selectLevelData1);
                                            //alert(selectLevelData2);


                                            var transUrl='dataTransferFyb';//传输数据的URL
                                            var transType='POST';
                                            var transAsync=false;//表明同步数据传输
                                            var columnName=['class_name', 'class_level', 'class_list_order','class_father_id'];
                                            var saveDataToBase=[];
                                            if(selectLevelData1=='无'){
                                                saveDataToBase=[levelName,'1',levelOrder,'0'];
                                            }else{
                                                var selLevDataMatrix1=selectLevelData1.split('|');
                                                if(selectLevelData2=='无'){
                                                    saveDataToBase=[levelName,'2',levelOrder,selLevDataMatrix1[0]];
                                                }else{
                                                    var selLevDataMatrix2=selectLevelData2.split('|');
                                                    saveDataToBase=[levelName,'3',levelOrder,selLevDataMatrix2[0]];
                                                }

                                            }
                                            var transData={
                                                table:dbTableHead + 'classify_infor',
                                                sqlType:'insert',
                                                column:matrixTransStringForSqlColumn(columnName),
                                                saveData:matrixTransStringForSqlColumn(saveDataToBase),//保存数据时，需要保存的数据
                                                userAccount:userAccount,
                                                enterAccount:enterAccount,
                                            };
                                            insertData=dataTransferFyb(transUrl,transType,transAsync,transData,);
                                            if(insertData[0]['insert']>0 ){
                                                alert('分类新增成功！');
                                                window.location.href='classifyInforAdd'
                                            }else if(insertData[0]['insert']==0){
                                                alert('分类新增失败，请重新添加！');
                                            }else{}
                                        }

                                        var btnDel = document.getElementById("deleteButtonFyb");
                                        btnDel.onclick =function(){
                                            var selectLevel1=document.getElementById('form-level-1');
                                            var selectLevelData1=selectLevel1.value;

                                            var selectLevel2=document.getElementById('form-level-2');
                                            var selectLevelData2=selectLevel2.value;

                                            var selectLevel3=document.getElementById('form-level-3');
                                            var selectLevelData3=selectLevel3.value;


                                            var transDelData={
                                                table:dbTableHead + 'classify_infor',
                                                sqlType:'delete',
                                                userAccount:userAccount,
                                                enterAccount:enterAccount,
                                                delResColumn:'',//约束的列名称
                                                delResValue:'',//约束的数据
                                            };
                                            if(selectLevelData1=='无'){
                                            }else{
                                                var selLevDataMatrix1=selectLevelData1.split('|');
                                                if(selectLevelData2=='无'){
                                                    transDelData['delResColumn']='id';
                                                    transDelData['delResValue']=selLevDataMatrix1[0];
                                                    var delData=dataTransferFyb('dataTransferFyb','POST',false,transDelData,);
                                                    transDelData['delResColumn']='class_father_id';
                                                    dataTransferFyb('dataTransferFyb','POST',false,transDelData,);
                                                    window.location.href='classifyInforAdd';
                                                }else{
                                                    if(selectLevelData3=='无'){
                                                        var selLevDataMatrix2=selectLevelData2.split('|');
                                                        transDelData['delResColumn']='id';
                                                        transDelData['delResValue']=selLevDataMatrix2[0];
                                                        var delData=dataTransferFyb('dataTransferFyb','POST',false,transDelData,);
                                                        transDelData['delResColumn']='class_father_id';
                                                        dataTransferFyb('dataTransferFyb','POST',false,transDelData,);
                                                        window.location.href='classifyInforAdd';
                                                    }else{
                                                        var selLevDataMatrix3=selectLevelData3.split('|');
                                                        transDelData['delResColumn']='id';
                                                        transDelData['delResValue']=selLevDataMatrix3[0];
                                                        dataTransferFyb('dataTransferFyb','POST',false,transDelData,);
                                                        window.location.href='classifyInforAdd';
                                                    }
                                                }

                                            }
                                        }

                                </script>


                                <script>


                                </script>



                                <!--结束写入正文-->
                                <!--测试-->

                                <!--测试结束-->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--footer,显示版权信息-->
    <script>
        copyRightAceFyb('长安大学汽车学院物流工程系', 'https://qiche.chd.edu.cn/2020/1208/c8529a173474/page.htm/', '2021');
    </script>

</div>

</body>
</html>